package com.shengbo.product.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyRabbitConfig {
    public static final String product1 = "topic.1.product";
    public static final String product2 = "topic.2.product";
    @Bean
    Queue topicProduct1Queue(){
        return new Queue(MyRabbitConfig.product1,true,false,false);
    }
    @Bean
    Queue topicProduct2Queue(){
        return new Queue(MyRabbitConfig.product2,true,false,false);
    }
    @Bean
    Exchange topicExchange(){
        return new TopicExchange("product-attr-exchange", true, false);
    }

    @Bean
    Binding topicBinding1(){
        return new Binding(MyRabbitConfig.product1, Binding.DestinationType.QUEUE, "product-attr-exchange", "topic.1.#", null);
    }

    @Bean
    Binding topicBinding2(){
        return new Binding(MyRabbitConfig.product2, Binding.DestinationType.QUEUE, "product-attr-exchange", "topic.2.#", null);
    }
}
